package sv.com.globalsolutionslt.manejador;

import sv.com.globalsolutionslt.entidades.TipoCargo;
import java.io.Serializable;
import java.util.Calendar;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.event.ActionEvent;
import javax.inject.Named;
import javax.faces.view.ViewScoped;
import sv.com.globalsolutionslt.controlador.TipoCargoFacade;
import sv.com.globalsolutionslt.entidades.AreaEmpresa;

@Named(value = "tipoCargoController")
@ViewScoped
public class TipoCargoController extends AbstractController<TipoCargo> implements Serializable {

    @EJB
    private TipoCargoFacade tipoCargoFacade;
    private List<TipoCargo> ltipoCargo;

    public TipoCargoController() {
        super(TipoCargo.class);
        ltipoCargo = null;
    }

    public List<TipoCargo> getLtipoCargo(AreaEmpresa a) {

        ltipoCargo = null;
        if (a != null) {
            ltipoCargo = tipoCargoFacade.TipoCargoActivo(a.getIdAreaEmpresa());
        }
        return ltipoCargo;
    }

    @Override
    public void save(ActionEvent event) {
        this.getSelected().setFechaMod(Calendar.getInstance().getTime());
        this.getSelected().setUsuarioMod(1);
        super.save(event); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void saveNew(ActionEvent event) {
        this.getSelected().setFechaMod(Calendar.getInstance().getTime());
        this.getSelected().setUsuarioMod(1);
        super.saveNew(event); //To change body of generated methods, choose Tools | Templates.
    }

}
